package com.cowcowit.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;


@Component
public class ReceiveMessageListenerController {
    @Value("${server.port}")
    private String serverPort;

    @Bean
    public Consumer<Message<String>> input() {
        System.out.println("=== 注册消息消费者 ===");
        return message -> {
            System.out.println("===== 消费者1号接收到消息 =====");
            System.out.println("消息内容: " + message.getPayload());
            System.out.println("端口: " + serverPort);
            System.out.println("消息头: " + message.getHeaders());
        };
    }
}



